package ys.ewp.facade;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import ys.ewp.dto.ColumnDto;
import ys.ewp.po.Column;
import ys.ewp.service.ColumnService;

@Component
public class ColumnFacade {

	@Resource
	private ColumnService columnService;
	
	/**
	 * @功能 获取所有栏目
	 * @return 
	 */
	public List<ColumnDto> getColumnList(){
		List<Column> colList = columnService.getList();
		return this.getDtoListByPoList(colList);
	}
	
	/**
	 * @功能 根据栏目PO列表获取栏目DTO列表
	 * @param colList 栏目PO列表
	 * @return 栏目DTO列表
	 */
	private List<ColumnDto> getDtoListByPoList(List<Column> colList){
		
		if(colList == null || colList.isEmpty()){
			return Collections.emptyList();
		}
		List<ColumnDto> colDtoList = new ArrayList<ColumnDto>();
		for(Column col : colList){
			ColumnDto colDto = null;
			colDto = ColumnDto.getDtoByPo(col);
			
			colDtoList.add(colDto);
		}
		return colDtoList;
	}
	
}
